package cn.fourhundredandeighteen;

import javax.swing.*;
import java.awt.*;

/**
 * @description:test类
 * @author: liuyongqi
 * @time: 2020/12/18
 */
public class Test extends JPanel {
    ImageIcon icon;
    Image img;

    public Test() {
        //  /img/HomeImg.jpg 是存放在你正在编写的项目的bin文件夹下的img文件夹下的一个图片
        icon = new ImageIcon(getClass().getResource("/Users/songzhangfeng/IdeaProjects/student-management/src/main/resources/Images/login.png"));
        img = icon.getImage();
    }

    public static void main(String[] args) {
//        JFrame jFrame = new JFrame();
//        jFrame.add(new Test());
//        jFrame.setVisible(true);
        long startTime = System.currentTimeMillis();
        long endTime = startTime + 1000;
        long index = 0;
        while (true) {
            double x = Math.sqrt(index);
            long now = System.currentTimeMillis();
            if (now > endTime) {
                break;
            }
            index++;
        }
        System.out.println(index + " Loops in 1 seconds");

    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        //下面这行是为了背景图片可以跟随窗口自行调整大小，可以自己设置成固定大小
        g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
    }

}